<?php
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
if(!isset($_SESSION['db'])){
	$addressbrowser = $_SERVER['SERVER_NAME'];
	$temp = explode(".", $addressbrowser);
	$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
	//$connection = mysql_connect("localhost", "root", "root" ) ;
	mysql_select_db("elihan", $connection);
	mysql_query("set names 'utf8'");
	$selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
	$result = mysql_fetch_assoc($selectdatabase);

	$_SESSION['Logo']=$result[Logo];
		
	$_SESSION['db']= $result[DatabaseName];
	mysql_close($connection);
}
$database = $_SESSION['db'];
$connectadmin = mysql_connect("1.234.53.52", "cam", "5678") or die("Không kết nối được database");
//$connectadmin = mysql_connect("localhost", "root", "root") or die("Không kết nối được database");
		mysql_select_db("elihan", $connectadmin);
		mysql_query("set names 'utf8'");
		
$selectprofilecomp = mysql_query("SELECT eli.PartnerName, eli.Address FROM ac_eli_manager eli where eli.DatabaseName='$database'");

$row = mysql_fetch_assoc($selectprofilecomp);
mysql_close($connectadmin);
?>
<?php

include '../../operations/connection.php';
$idempcerficate = $_REQUEST['idempcerficate'];
$newlang = $_REQUEST['newlang'];

if ($_REQUEST['newlang'] == "EN") {
	include "../../value/value_en.php";
} else if($_REQUEST['newlang'] == "VN") {
	include "../../value/value_vn.php";
}
else {
	include "../../value/value_kr.php";
}

$selectempcertifi = mysql_query("SELECT e.FullName, e.CMND,e.Address,e.Position,e.CurrentJob,
		DATE_FORMAT(e.StartDate,'%Y-%m-%d') as StartDate,DATE_FORMAT(e.EndDate,'%Y-%m-%d') as EndDate,dl.DepartmentName  
		FROM employee e,department_lang dl ,department dp 
		WHERE e.IDDepartment = dl.IDDepartment AND dp.IDDepartment = dl.IDDepartment AND dl.LangID ='$newlang'
		AND e.IDEmployee = '$idempcerficate'");

$resultemp = mysql_fetch_assoc($selectempcertifi);

?>

<div style="margin-left: 5px;">
	<div style="height: 10px;"></div>
	<div class="navigation-button" style="background-color: #eef1f3;">
		<a href="#" onclick="onclickback(this)"><img
			src="images/back-admin.png" /> </a>
		<div><?php echo $l_back?></div>
	</div>
	<div class="navigation-button" style="background-color: #eef1f3;">
			<a href="admin/employeemanagement/print-employee-certificate.php?idempcerficates=<?=$idempcerficate?>" target="_blank"><input type="submit" name="print" id="print" value="" 
				style="background: url('images/print-admin.png') no-repeat 40px center;
				 width: 100px; height: 30px;border-bottom: none;border-right: none;cursor: pointer;"></a>
				  <div><?php echo $l_print?></div>
		</div>
	
	<br style="clear: both" /> <br />
	<div class="credential-form">
		<div class="credential-form-title"><?php echo $l_emplcertifi?></div>
		<table class="credential-form-table" border="1" width="90%">
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_fullname?></b></td>
				<td><?php echo $resultemp[FullName]?></td>
				<td bgcolor="#EEEEEE"><b><?php echo $l_responsibilities?></b></td>
				<td><?php echo $resultemp[CurrentJob]?></td>
			</tr>
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_cmnd?></b></td>
				<td colspan="3"><?php echo $resultemp[CMND]?></td>
			</tr>
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_dept?></b></td>
				<td><?php echo $resultemp[DepartmentName]?></td>
				<td bgcolor="#EEEEEE"><b><?php echo $l_office?></b></td>
				<td><?php echo $resultemp[Position]?></td>
			</tr>
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_timework?></b></td>
				<td colspan="2">
				<span style="margin-right: 5px"><?php echo $l_startwork?></span>
				 <span style="margin-right: 10px"><?php echo $l_from?></span>
				 <span id="dateFrom">
				 <?php if ($newlang=="EN"){echo $resultemp[StartDate];}
					 else if($newlang=="VN"){
					 	$day = date('d',strtotime($resultemp[StartDate]));$month = date('m',strtotime($resultemp[StartDate]));$year=date('Y',strtotime($resultemp[StartDate]));
						 echo "Ngày ".$day." Tháng ".$month." Năm ".$year;}
					 else if($newlang=="KR"){
					 	$day = date('d',strtotime($resultemp[StartDate]));$month = date('m',strtotime($resultemp[StartDate]));$year=date('Y',strtotime($resultemp[StartDate]));
					 	echo $year." 년  ".$month." 월  ".$day." 일";
					 }
				  ?></span>
					<br /> <br /> 
				<span style="margin-right: 5px"><?php echo $l_totoday?></span> <span
					style="margin-right: 10px"><?php echo ""?></span>
					<span id="dateTo"><?php  if ($newlang=="EN"){ echo $resultemp[EndDate];}
					 else if($newlang=="VN"){
					 	$day = date('d',strtotime($resultemp[EndDate]));$month = date('m',strtotime($resultemp[EndDate]));$year=date('Y',strtotime($resultemp[EndDate]));
						 echo "Ngày ".$day." Tháng ".$month." Năm ".$year;}
					 else if($newlang=="KR"){
					 	$day = date('d',strtotime($resultemp[EndDate]));$month = date('m',strtotime($resultemp[EndDate]));$year=date('Y',strtotime($resultemp[EndDate]));
					 	echo $year." 년  ".$month." 월  ".$day." 일";
					 }
					?></span>
					<br /> <br /> 
				<span style="font-size: 15px;" id="date"></span>
				</td>
				<td><?php echo "";?></td>
			</tr>
		</table>

		<div class="credential-form-info">
			<br /> <span style="font-size: 14px; font-weight: bold;"><?php echo $l_certifiabove?></span> <span
				style="font-size: 15px; margin: 130px 0px 0px 0px" id="date2">
				<?php if ($newlang=="EN"){$datetime = date('Y-m-d') ;echo $datetime;}
					else if($newlang=="VN"){$day = date('d');$month = date('m');$year=date('Y');
						echo "Ngày ".$day." Tháng ".$month." Năm ".$year;}
					else if($newlang=="KR"){$day = date('d');$month = date('m');$year=date('Y'); 
						echo $year." 년  ".$month." 월  ".$day." 일";}
				?>
				</span>
			<div
				style="font-size: 16px; text-transform: uppercase; margin: 130px 0px 0px 0px"
				align="center">
				<span style="width: 220px;"><?php echo $row[Address]?></span>
			</div>
			<div
				style="font-size: 16px; font-weight: bold; text-transform: uppercase; margin: 10px 0px 0px 0px">
				<?php echo $row[PartnerName]?></div>
		</div>
	</div>
</div>
<?php mysql_close($connection);?>
